﻿namespace Pub.Class
{
    using System;
    using System.Runtime.CompilerServices;

    public static class FloatExtensions
    {
        public static decimal PercentageOf(this float value, double percentOf)
        {
            return (decimal) ((((double) value) / percentOf) * 100.0);
        }

        public static decimal PercentageOf(this float value, int percentOf)
        {
            return (decimal) ((value / ((float) percentOf)) * 100f);
        }

        public static decimal PercentageOf(this float value, long percentOf)
        {
            return (decimal) ((value / ((float) percentOf)) * 100f);
        }

        public static decimal PercentageOf(this float value, float percentOf)
        {
            return (decimal) ((value / percentOf) * 100f);
        }

        public static float Round(this float val, int decimalPoints)
        {
            return (float) Math.Round((double) val, decimalPoints);
        }

        public static float Round2(this float val)
        {
            return (float) Math.Round((double) val, 2);
        }

        public static string ToCurrency(this int value)
        {
            return value.ToString("N");
        }
    }
}

